﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication2.DAL;

namespace WebApplication2.Controllers
{
    public class AccountController : Controller
    {
        // GET: Account
        public ActionResult Index()
        {
            return View();
        }


        public ActionResult Login()
        {
            ViewBag.LoginState = "登录前...";
            return View();
        }

        private AccountContext DB = new AccountContext();

        [HttpPost]
        public ActionResult Login(FormCollection fc)
        {
            string firstname = fc["firstname"];
            string lastname = fc["lastname"];

            var user = DB.SysUsers.Where(a => a.UserName == firstname && a.Password == lastname);
            if (user.Count() > 0)
            {
                ViewBag.LoginState = "登录成功..." + firstname;
                return Redirect("Index/Index");
            }
            else
            {

                ViewBag.LoginState = "用户不存在..." + firstname;
            }
          
            return View();
        }


        public ActionResult Register()
        {
          

            return View();
        }

       
    }
}